package cn.seqdata.tree;

import org.springframework.util.StringUtils;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonInclude.Include;

public class TextTreeNode extends TreeNode {
	private final Object id;
	private final String text;
	private final String clz;

	public TextTreeNode(Object id, String text, String clz) {
		this(id, text, clz, false);
	}

	public TextTreeNode(Object id, String text, String clz, boolean container) {
		super(container);

		this.id = id;
		this.text = text;
		this.clz = clz;
	}

	@Override
	public String getId() {
		return String.valueOf(id);
	}

	@Override
	public String getText() {
		return StringUtils.isEmpty(text) ? String.valueOf(getId()) : text;
	}

	@JsonInclude(Include.NON_NULL)
	@Override
	public String getClz() {
		return clz;
	}
}
